/*******公用function by lzd 2012-01-16*******/
$.fn.form2json = function(){
	var formId = $(this).attr("id");
	var t = (new Date()).valueOf();
	var serializedParams = qkb.pubFun.serialize(formId,"1") + '&t='+ t +'&sign=' + hex_md5(qkb.pubFun.serialize(formId,"2")+ '&' + t);
	var obj = qkb.pubFun.paramStringToObj(serializedParams);
	return qkb.pubFun.ObjToStr(obj);
},
$.fn.form2json2 = function(){
	var formId = $(this).attr("id");
	var serializedParams2 = qkb.pubFun.serialize(formId,"1");
	var obj2 = qkb.pubFun.paramStringToObj(serializedParams2);
	return qkb.pubFun.ObjToStr(obj2);
},
/**
*plugin name: 搜索框去除提示默认值
*description: focus,blur聚焦默认文字显示隐藏
*             Enter提交表单搜索
**/
$.fn.inputfocus = function(v){
	$(this).focus(function(){
		if($(this).val() == v){
			$(this).val("");
		}
	}).blur(function(){
		if($(this).val()==""){
			$(this).val(v);
		}
	});
},
 /**
 *plugin name: 下拉选项菜单
 *description: 显示下拉菜单，点击选择项，并给对应对象赋值
 **/
 $.fn.dropList=function(options){
  var defaults={
   obj:".drop_list",  //下拉框class，id
   effect:'slide', //显示效果, normal-show(),hide(); slide-slideUp(),slideDown(); fade-fadeIn(),fadeOut();
   stime:600,   //显示过渡时间
   htime:400,   //隐藏过渡时间
   events:'click'      //触发事件,click-点击,hover-鼠标滑过
  };
  var o=$.extend(defaults,options);
  var obj=$(o.obj);
  
  if(obj.length==0) return;
  
  //判断触发事件类型
  switch(o.events){
   case 'click':
    this.toggle(function(){
     display(obj,o.effect,o.time);
    },function(){
     hide(obj,o.effect,o.time);
    });
    break;
   case 'hover':
    this.hover(function(){
     display(obj,o.effect,o.time);
    },function(){
     hide(obj,o.effect,o.time);
    });
    break;
  }
  
  //下拉框显示函数（下拉框对象，类型，事件）
  function display(object,tp,tm){
   switch(tp){
    case 'normal':
     //object.filter(":not(:animated)").show(tm);
     if(!object.is(":animated")) object.show(tm);
     break;
    case 'fade':
     //object.filter(":not(:animated)").fadeIn(tm);
     if(!object.is(":animated")) object.fadeIn(tm);
     break;
    case 'slide':
     //object.filter(":not(:animated)").slideDown(tm);
     if(!object.is(":animated")) object.slideDown(tm);
     break;
   }
  }
  
  //下拉框隐藏函数（下拉框对象，类型，事件）
  function hide(object,tp,tm){
   switch(tp){
    case 'normal':
     //object.filter(":not(:animated)").hide(tm);
     if(!object.is(":animated")) object.hide(tm);
     break;
    case 'fade':
     //object.filter(":not(:animated)").fadeOut(tm);
     if(!object.is(":animated")) object.fadeOut(tm);
     break;
    case 'slide':
     //object.filter(":not(:animated)").slideUp(tm);
     if(!object.is(":animated")) object.slideUp(tm);
     break;
   }
  }
 }
